package com.wpw.dream.instance;

public class Teacher extends Person {

	private Long id;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Teacher(String name, Long id) {
		super(name);
		this.id = id;
	}
	
	@Override
	public boolean equals(Object obj) {
//		if (obj.getClass() == Teacher.class) {
		if (obj instanceof Teacher) {
			Teacher teacher = (Teacher) obj;
			return super.equals(obj) && teacher.getId() == id;  
		}
		return false;
	}
	
	@Override
	public String toString() {
		return "Teacher [id=" + id + "]";
	}

	public static void main(String[] args) {
		Person p = new Person("小红");
		Teacher t1 = new Teacher("小红", 1L);
		Teacher t2 = new Teacher("小红", 2L);
		System.out.println(p.equals(t1));
		System.out.println(p.equals(t2));
		System.out.println(t2.equals(t1));
		
		t1.finalFunction();
		/*String a = "a";
		String b = "a";
		String c = new String("a");
		String d = new String("a");
		String e = new String(a);
		String f = a;
		String ab = "a" + "b";
		String AB = "ab";
		String ajb = a + b;

		System.out.println(a == b);
		System.out.println(a == c);
		System.out.println(c == d);
		System.out.println(a == e);
		System.out.println(f == a);
		System.out.println(f == e);
		System.out.println(ab == AB);
		System.out.println(ab == ajb);
		System.out.println(ajb == AB);*/
		
		
		
	}
	
	
}
